import { Injectable } from '@nestjs/common';
import { PrismaService } from 'src/prisma/prisma.service';
import { CreateTowerDto } from './dto/create-tower.dto';
import { UpdateTowerDto } from './dto/update-tower.dto';

@Injectable()
export class TowerService {
  constructor(private prisma: PrismaService) {}

  async createMany(createTowerDtos: CreateTowerDto[]) {
    return await this.prisma.tower.createMany({ data: createTowerDtos });
  }

  async removeMany(id: number) {
    return await this.prisma.tower.deleteMany({
      where: {
        lineId: id,
      },
    });
  }

  create(createTowerDto: CreateTowerDto) {
    return 'This action adds a new tower';
  }

  async findAll(args: Record<string, any>) {
    const { lineId } = args;
    return await this.prisma.tower.findMany({
      where: {
        lineId: +lineId,
      },
    });
  }

  findOne(id: number) {
    return `This action returns a #${id} tower`;
  }

  update(id: number, updateTowerDto: UpdateTowerDto) {
    return `This action updates a #${id} tower`;
  }

  remove(id: number) {
    return `This action removes a #${id} tower`;
  }
}
